/* --------------------------------------------------------------- */
function validatorValidateString(string, validityMode) {
  switch(validityMode) {
    /* check if string is null ---------------- */
    case 'NOT_NULL':
      return (trim(string) != '');
      break;
      
    /* check email ---------------------------- */ 
    case 'EMAIL':
	  var atomChars = '[-a-z0-9!#$%&\'*+\\\\/=?^_`{|}~]';
  	  var domainChars = '([a-z0-9]([-a-z0-9]*[a-z0-9]+)?)';
	  var eml_regexp = new RegExp('^'+atomChars+'+(?:\\.'+atomChars+'+)*@('+domainChars+'{2,63}\\.)+'+domainChars+'{2,63}$','i');
	  return eml_regexp.test(string);
      break;
      
    /* check telephone ------------------------ */
    case 'TELEPHONE':
      var pattern = /^\d{10,11}$/;
      return pattern.test(string);
      break;
      
    /* default -------------------------------- */
    default:
      return true;
      break;
    
  }
}